package edos.prm.log;

import edos.prm.activity.Activity;
import edos.prm.event.Event;
import edos.prm.process.ProcessAction;
import edos.prm.role.RoleException;
import edos.prm.task.Task;
import java.util.Set;

/**
 * The {@code LogManager} is responsible for handling the PRM engine's log(s).
 * 
 * @author Ciaran
 */
public interface LogManager extends Activity {
	
	/**
	 * Create a new log with the given name
	 * 
	 * @param name the String name of the log
	 * @return a newly created log
	 * @throws RoleException if the caller does not possess the right to call
	 * this operation.
	 */
	public Log newLog(String name) throws RoleException;
	
	/**
	 * Records a process action in the log
	 * 
	 * @param log the log where the action is recorded
	 * @param action this action gets recorded in the log
	 * @throws RoleException if the caller does not possess the right to call
	 * this operation.
	 */
	public void record(Log log, ProcessAction action) throws RoleException;
	
	/**
	 * Record the raising of an event in the PRM's engine.
	 * 
	 * @param log the log where the event is recorded
	 * @param event the event being recorded
	 * @throws RoleException if the caller does not possess the right to call
	 * this operation.
	 */
	public void record(Log log, Event event) throws RoleException;
	
	/**
	 * Dumps the content of the log to some output device
	 * 
	 * @param log the log whose contents are dumped to an output.
	 * @throws RoleException if the caller does not possess the right to call
	 * this operation.
	 */
	public void dump(Log log) throws RoleException;
	
	/**
	 * Queries a log for the set of actions executed by a task
	 * 
	 * @param task the task being queried
	 * @return the set of actions executed within this task
	 * @throws RoleException if the caller does not possess the right to call
	 * this operation.
	 */
	public Set<ProcessAction> queryActions(Task task) throws RoleException;
	
	/**
	 * Queries a log for the set of events that have been raised by a task
	 * 
	 * @param task the task whose behavior is being queried
	 * @return the set of events raised by this task
	 * @throws RoleException if the caller does not possess the right to call
	 * this operation.
	 */
	public Set<Event> queryEvents(Task task) throws RoleException;
}
